Repetier-Firmware  1.0.0
motion.h
Go to the documentation of this file.
1 /*
2  This file is part of Repetier-Firmware.
3 
4  Repetier-Firmware is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Repetier-Firmware is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
16 
17  This firmware is a nearly complete rewrite of the sprinter firmware
18  by kliment (https://github.com/kliment/Sprinter)
19  which based on Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
20 #
21  Functions in this file are used to communicate using ascii or repetier protocol.
22 */
23 
24 #ifndef MOTION_H_INCLUDED
25 #define MOTION_H_INCLUDED
26 
28 #define FLAG_WARMUP 1
29 #define FLAG_NOMINAL 2
30 #define FLAG_DECELERATING 4
31 #define FLAG_ACCELERATION_ENABLED 8 // unused
32 #define FLAG_CHECK_ENDSTOPS 16
33 #define FLAG_ALL_E_MOTORS 32 // For mixed extruder move all motors instead of selected motor
34 #define FLAG_SKIP_DEACCELERATING 64 // unused
35 #define FLAG_BLOCKED 128
36 
38 #define FLAG_JOIN_STEPPARAMS_COMPUTED 1
39 
40 #define FLAG_JOIN_END_FIXED 2
41 
42 #define FLAG_JOIN_START_FIXED 4
43 
44 #define FLAG_JOIN_START_RETRACT 8
45 
46 #define FLAG_JOIN_END_RETRACT 16
47 
48 #define FLAG_JOIN_NO_RETRACT 32
49 
50 #define FLAG_JOIN_WAIT_EXTRUDER_UP 64
51 
52 #define FLAG_JOIN_WAIT_EXTRUDER_DOWN 128
53 // Printing related data
54 #if NONLINEAR_SYSTEM || defined(DOXYGEN)
55 // Allow the delta cache to store segments for every line in line cache. Beware this gets big ... fast.
56 
57 class PrintLine;
58 typedef struct {
60  uint16_t deltaSteps[TOWER_ARRAY];
61  inline bool checkEndstops(PrintLine *cur, bool checkall);
62  inline void setXMoveFinished() {
63  dir &= ~XSTEP;
64  }
65  inline void setYMoveFinished() {
66  dir &= ~YSTEP;
67  }
68  inline void setZMoveFinished() {
69  dir &= ~ZSTEP;
70  }
71  inline void setXYMoveFinished() {
72  dir &= ~XY_STEP;
73  }
74  inline bool isXPositiveMove() {
75  return (dir & X_STEP_DIRPOS) == X_STEP_DIRPOS;
76  }
77  inline bool isXNegativeMove() {
78  return (dir & X_STEP_DIRPOS) == XSTEP;
79  }
80  inline bool isYPositiveMove() {
81  return (dir & Y_STEP_DIRPOS) == Y_STEP_DIRPOS;
82  }
83  inline bool isYNegativeMove() {
84  return (dir & Y_STEP_DIRPOS) == YSTEP;
85  }
86  inline bool isZPositiveMove() {
87  return (dir & Z_STEP_DIRPOS) == Z_STEP_DIRPOS;
88  }
89  inline bool isZNegativeMove() {
90  return (dir & Z_STEP_DIRPOS) == ZSTEP;
91  }
92  inline bool isEPositiveMove() {
93  return (dir & E_STEP_DIRPOS) == E_STEP_DIRPOS;
94  }
95  inline bool isENegativeMove() {
96  return (dir & E_STEP_DIRPOS) == ESTEP;
97  }
98  inline bool isXMove() {
99  return (dir & XSTEP);
100  }
101  inline bool isYMove() {
102  return (dir & YSTEP);
103  }
104  inline bool isXOrYMove() {
105  return dir & XY_STEP;
106  }
107  inline bool isZMove() {
108  return (dir & ZSTEP);
109  }
110  inline bool isEMove() {
111  return (dir & ESTEP);
112  }
113  inline bool isEOnlyMove() {
114  return (dir & XYZE_STEP) == ESTEP;
115  }
116  inline bool isNoMove() {
117  return (dir & XYZE_STEP) == 0;
118  }
119  inline bool isXYZMove() {
120  return dir & XYZ_STEP;
121  }
122  inline bool isMoveOfAxis(uint8_t axis) {
123  return (dir & (XSTEP << axis));
124  }
125  inline void setMoveOfAxis(uint8_t axis) {
126  dir |= XSTEP << axis;
127  }
128  inline void setPositiveMoveOfAxis(uint8_t axis) {
129  dir |= X_STEP_DIRPOS << axis;
130  }
131  inline void setPositiveDirectionForAxis(uint8_t axis) {
132  dir |= X_DIRPOS << axis;
133  }
135 extern uint8_t lastMoveID;
136 #endif
137 class UIDisplay;
138 class PrintLine { // RAM usage: 24*4+15 = 113 Byte
139  friend class UIDisplay;
140 #if CPU_ARCH == ARCH_ARM
141  static volatile bool nlFlag;
142 #endif
143 public:
144  static ufast8_t linesPos; // Position for executing line movement
145  static PrintLine lines[];
146  static ufast8_t linesWritePos; // Position where we write the next cached line move
148  volatile ufast8_t flags;
149  secondspeed_t secondSpeed; // for laser intensity or fan control
150 private:
153  int32_t timeInTicks;
154  int32_t delta[E_AXIS_ARRAY];
155  int32_t error[E_AXIS_ARRAY];
156  float speedX;
157  float speedY;
158  float speedZ;
159  float speedE;
160  float fullSpeed;
161  float invFullSpeed;
164  float startSpeed;
165  float endSpeed;
166  float minSpeed;
167  float distance;
168 #if NONLINEAR_SYSTEM || defined(DOXYGEN)
170  uint8_t moveID;
173 #endif
175  uint32_t accelSteps;
176  uint32_t decelSteps;
177  uint32_t accelerationPrim;
178  uint32_t fAcceleration;
182 #if USE_ADVANCE
183 #if ENABLE_QUADRATIC_ADVANCE
184  int32_t advanceRate;
185  int32_t advanceFull;
186  int32_t advanceStart;
187  int32_t advanceEnd;
188 #endif
189  uint16_t advanceL;
190 #endif
191 #ifdef DEBUG_STEPCOUNT
192  int32_t totalStepsRemaining;
193 #endif
194 public:
195  int32_t stepsRemaining;
196  static PrintLine *cur;
197  static volatile ufast8_t linesCount; // Number of lines cached 0 = nothing to do
198  inline bool areParameterUpToDate() {
199  return joinFlags & FLAG_JOIN_STEPPARAMS_COMPUTED;
200  }
201  inline void invalidateParameter() {
202  joinFlags &= ~FLAG_JOIN_STEPPARAMS_COMPUTED;
203  }
204  inline void setParameterUpToDate() {
205  joinFlags |= FLAG_JOIN_STEPPARAMS_COMPUTED;
206  }
207  inline bool isStartSpeedFixed() {
208  return joinFlags & FLAG_JOIN_START_FIXED;
209  }
210  inline void setStartSpeedFixed(bool newState) {
211  joinFlags = (newState ? joinFlags | FLAG_JOIN_START_FIXED : joinFlags & ~FLAG_JOIN_START_FIXED);
212  }
213  inline void fixStartAndEndSpeed() {
215  }
216  inline bool isEndSpeedFixed() {
217  return joinFlags & FLAG_JOIN_END_FIXED;
218  }
219  inline void setEndSpeedFixed(bool newState) {
220  joinFlags = (newState ? joinFlags | FLAG_JOIN_END_FIXED : joinFlags & ~FLAG_JOIN_END_FIXED);
221  }
222  inline bool isWarmUp() {
223  return flags & FLAG_WARMUP;
224  }
225  inline uint8_t getWaitForXLinesFilled() {
226  return primaryAxis;
227  }
228  inline void setWaitForXLinesFilled(uint8_t b) {
229  primaryAxis = b;
230  }
231  inline bool isExtruderForwardMove() {
232  return (dir & E_STEP_DIRPOS) == E_STEP_DIRPOS;
233  }
234  inline void block() {
235  flags |= FLAG_BLOCKED;
236  }
237  inline void unblock() {
238  flags &= ~FLAG_BLOCKED;
239  }
240  inline bool isBlocked() {
241  return flags & FLAG_BLOCKED;
242  }
243  inline bool isAllEMotors() {
244  return flags & FLAG_ALL_E_MOTORS;
245  }
246  inline bool isCheckEndstops() {
247  return flags & FLAG_CHECK_ENDSTOPS;
248  }
249  inline bool isNominalMove() {
250  return flags & FLAG_NOMINAL;
251  }
252  inline void setNominalMove() {
253  flags |= FLAG_NOMINAL;
254  }
255  inline void checkEndstops() {
256  if(isCheckEndstops()) {
261  else if(isXPositiveMove() && Endstops::xMax())
265  else if(isYPositiveMove() && Endstops::yMax())
267 #if FEATURE_Z_PROBE
271  } else
272 #endif
273 #if MULTI_ZENDSTOP_HOMING
274  {
275  if(Printer::isHoming()) {
276  if(isZNegativeMove()) {
277  if(Endstops::zMin())
279  if(Endstops::z2MinMax())
281  if(Printer::multiZHomeFlags == 0)
283  } else if(isZPositiveMove()) {
284  if(Endstops::zMax())
286  if(Endstops::z2MinMax())
288  if(Printer::multiZHomeFlags == 0) {
289 #if MAX_HARDWARE_ENDSTOP_Z
291 #endif
293  }
294  }
295  } else {
296  if(isZNegativeMove() && Endstops::zMin()) {
298  } else if(isZPositiveMove() && Endstops::zMax()) {
299 #if MAX_HARDWARE_ENDSTOP_Z
301 #endif
303  }
304  }
305  }
306 #else
307  if(isZNegativeMove() && Endstops::zMin()) {
309  } else if(isZPositiveMove() && Endstops::zMax()) {
310 #if MAX_HARDWARE_ENDSTOP_Z
312 #endif
314  }
315 #endif
316  }
317 #if FEATURE_Z_PROBE
320  if(Endstops::zProbe()) {
323  }
324  }
325 #endif
326  }
327  }
328 
329  inline void setXMoveFinished() {
330 #if DRIVE_SYSTEM==XY_GANTRY || DRIVE_SYSTEM==YX_GANTRY
331  dir &= ~48;
332 #elif DRIVE_SYSTEM==XZ_GANTRY || DRIVE_SYSTEM==ZX_GANTRY
333  dir &= ~80;
334 #else
335  dir &= ~16;
336 #endif
337  }
338  inline void setYMoveFinished() {
339 #if DRIVE_SYSTEM==XY_GANTRY || DRIVE_SYSTEM==YX_GANTRY
340  dir &= ~48;
341 #else
342  dir &= ~32;
343 #endif
344  }
345  inline void setZMoveFinished() {
346 #if DRIVE_SYSTEM==XZ_GANTRY || DRIVE_SYSTEM==ZX_GANTRY
347  dir &= ~80;
348 #else
349  dir &= ~64;
350 #endif
351  }
352  inline void setXYMoveFinished() {
353  dir &= ~48;
354  }
355  inline bool isXPositiveMove() {
356  return (dir & X_STEP_DIRPOS) == X_STEP_DIRPOS;
357  }
358  inline bool isXNegativeMove() {
359  return (dir & X_STEP_DIRPOS) == XSTEP;
360  }
361  inline bool isYPositiveMove() {
362  return (dir & Y_STEP_DIRPOS) == Y_STEP_DIRPOS;
363  }
364  inline bool isYNegativeMove() {
365  return (dir & Y_STEP_DIRPOS) == YSTEP;
366  }
367  inline bool isZPositiveMove() {
368  return (dir & Z_STEP_DIRPOS) == Z_STEP_DIRPOS;
369  }
370  inline bool isZNegativeMove() {
371  return (dir & Z_STEP_DIRPOS) == ZSTEP;
372  }
373  inline bool isEPositiveMove() {
374  return (dir & E_STEP_DIRPOS) == E_STEP_DIRPOS;
375  }
376  inline bool isENegativeMove() {
377  return (dir & E_STEP_DIRPOS) == ESTEP;
378  }
379  inline bool isXMove() {
380  return (dir & XSTEP);
381  }
382  inline bool isYMove() {
383  return (dir & YSTEP);
384  }
385  inline bool isXOrYMove() {
386  return dir & XY_STEP;
387  }
388  inline bool isXOrZMove() {
389  return dir & (XSTEP | YSTEP);
390  }
391  inline bool isZMove() {
392  return (dir & ZSTEP);
393  }
394  inline bool isEMove() {
395  return (dir & ESTEP);
396  }
397  inline bool isEOnlyMove() {
398  return (dir & XYZE_STEP) == ESTEP;
399  }
400  inline bool isNoMove() {
401  return (dir & XYZE_STEP) == 0;
402  }
403  inline bool isXYZMove() {
404  return dir & XYZ_STEP;
405  }
406  inline bool isMoveOfAxis(uint8_t axis) {
407  return (dir & (XSTEP << axis));
408  }
409  inline void setMoveOfAxis(uint8_t axis) {
410  dir |= XSTEP << axis;
411  }
412  inline void setPositiveDirectionForAxis(uint8_t axis) {
413  dir |= X_DIRPOS << axis;
414  }
415  inline static void resetPathPlanner() {
416  linesCount = 0;
417  linesPos = linesWritePos;
419  }
420  // Only called from bresenham -> inside interrupt handle
421  inline void updateAdvanceSteps(speed_t v, uint8_t max_loops, bool accelerate) {
422 #if USE_ADVANCE
423  if(!Printer::isAdvanceActivated()) return;
424 #if ENABLE_QUADRATIC_ADVANCE
425  long advanceTarget = Printer::advanceExecuted;
426  if(accelerate) {
427  for(uint8_t loop = 0; loop < max_loops; loop++) advanceTarget += advanceRate;
428  if(advanceTarget > advanceFull)
429  advanceTarget = advanceFull;
430  } else {
431  for(uint8_t loop = 0; loop < max_loops; loop++) advanceTarget -= advanceRate;
432  if(advanceTarget < advanceEnd)
433  advanceTarget = advanceEnd;
434  }
435  long h = HAL::mulu16xu16to32(v, advanceL);
436  int tred = ((advanceTarget + h) >> 16);
439  if(tred > 0 && Printer::advanceStepsSet <= 0)
441  else if(tred < 0 && Printer::advanceStepsSet >= 0)
443  Printer::advanceStepsSet = tred;
445  Printer::advanceExecuted = advanceTarget;
446 #else
447  int tred = HAL::mulu6xu16shift16(v, advanceL);
450  if(tred > 0 && Printer::advanceStepsSet <= 0)
451  Printer::extruderStepsNeeded += (Extruder::current->advanceBacklash << 1);
452  else if(tred < 0 && Printer::advanceStepsSet >= 0)
453  Printer::extruderStepsNeeded -= (Extruder::current->advanceBacklash << 1);
454  Printer::advanceStepsSet = tred;
456 #endif
457 #endif
458  }
460  if(stepsRemaining <= static_cast<int32_t>(decelSteps)) {
461  if (!(flags & FLAG_DECELERATING)) {
462  Printer::timer = 0;
463  flags |= FLAG_DECELERATING;
464  }
465  return true;
466  } else return false;
467  }
470  }
472 #if !(GANTRY) || defined(FAST_COREXYZ)
474 #else
475 #if DRIVE_SYSTEM == XY_GANTRY || DRIVE_SYSTEM == XZ_GANTRY
476  if(isXPositiveMove()) {
477  Printer::motorX++;
479  } else {
480  Printer::motorX--;
482  }
483 #endif
484 #if DRIVE_SYSTEM == YX_GANTRY || DRIVE_SYSTEM == ZX_GANTRY
485  if(isXPositiveMove()) {
486  Printer::motorX++;
488  } else {
489  Printer::motorX--;
491  }
492 #endif
493 #endif
494 #ifdef DEBUG_STEPCOUNT
495  totalStepsRemaining--;
496 #endif
497  }
499 #if !(GANTRY) || DRIVE_SYSTEM == ZX_GANTRY || DRIVE_SYSTEM == XZ_GANTRY || defined(FAST_COREXYZ)
501 #else
502 #if DRIVE_SYSTEM == XY_GANTRY
503  if(isYPositiveMove()) {
504  Printer::motorX++;
506  } else {
507  Printer::motorX--;
509  }
510 #endif
511 #if DRIVE_SYSTEM == YX_GANTRY
512  if(isYPositiveMove()) {
513  Printer::motorX++;
515  } else {
516  Printer::motorX--;
518  }
519 #endif
520 #endif // GANTRY
521 #ifdef DEBUG_STEPCOUNT
522  totalStepsRemaining--;
523 #endif
524 
525  }
527 #if !(GANTRY) || DRIVE_SYSTEM == YX_GANTRY || DRIVE_SYSTEM == XY_GANTRY || defined(FAST_COREXYZ)
529 #else
530 #if DRIVE_SYSTEM == XZ_GANTRY
531  if(isZPositiveMove()) {
532  Printer::motorX++;
534  } else {
535  Printer::motorX--;
537  }
538 #endif
539 #if DRIVE_SYSTEM == ZX_GANTRY
540  if(isZPositiveMove()) {
541  Printer::motorX++;
543  } else {
544  Printer::motorX--;
546  }
547 #endif
548 #endif
549 #ifdef DEBUG_STEPCOUNT
550  totalStepsRemaining--;
551 #endif
552  }
553  void updateStepsParameter();
554  float safeSpeed(fast8_t drivingAxis);
555  void calculateMove(float axis_diff[], uint8_t pathOptimize, fast8_t distanceBase);
556  void logLine();
558  return timeInTicks;
559  }
560  INLINE void setWaitTicks(long wait) {
561  timeInTicks = wait;
562  }
563 
564  static INLINE bool hasLines() {
565  return linesCount;
566  }
567  static INLINE void setCurrentLine() {
568  cur = &lines[linesPos];
569 #if CPU_ARCH==ARCH_ARM
570  PrintLine::nlFlag = true;
571 #endif
572  }
573  // Only called from within interrupts
575  nextPlannerIndex(linesPos);
576  cur = NULL;
577 #if CPU_ARCH == ARCH_ARM
578  nlFlag = false;
579 #endif
581  --linesCount;
582  if(!linesCount)
584  }
585  static INLINE void pushLine() {
586  nextPlannerIndex(linesWritePos);
589  linesCount++;
590  }
591  static uint8_t getLinesCount() {
593  return linesCount;
594  }
596  return &lines[linesWritePos];
597  }
598  static inline void computeMaxJunctionSpeed(PrintLine *previous, PrintLine *current);
599  static int32_t bresenhamStep();
600  static void waitForXFreeLines(uint8_t b = 1, bool allowMoves = false);
601  static inline void forwardPlanner(ufast8_t p);
602  static inline void backwardPlanner(ufast8_t p, ufast8_t last);
603  static void updateTrapezoids();
604  static uint8_t insertWaitMovesIfNeeded(uint8_t pathOptimize, uint8_t waitExtraLines);
605  static void LaserWarmUp(uint32_t wait);
606 #if !NONLINEAR_SYSTEM || defined(DOXYGEN)
607  static void queueCartesianMove(uint8_t check_endstops, uint8_t pathOptimize);
608 #if DISTORTION_CORRECTION || defined(DOXYGEN)
609  static void queueCartesianSegmentTo(uint8_t check_endstops, uint8_t pathOptimize);
610 #endif
611 #endif
612  static void moveRelativeDistanceInSteps(int32_t x, int32_t y, int32_t z, int32_t e, float feedrate, bool waitEnd, bool check_endstop, bool pathOptimize = true);
613  static void moveRelativeDistanceInStepsReal(int32_t x, int32_t y, int32_t z, int32_t e, float feedrate, bool waitEnd, bool pathOptimize = true);
614 #if ARC_SUPPORT || defined(DOXYGEN)
615  static void arc(float *position, float *target, float *offset, float radius, uint8_t isclockwise);
616 #endif
618  p = (p ? p - 1 : PRINTLINE_CACHE_SIZE - 1);
619  }
620  static INLINE void nextPlannerIndex(ufast8_t& p) {
621  p = (p >= PRINTLINE_CACHE_SIZE - 1 ? 0 : p + 1);
622  }
623 #if NONLINEAR_SYSTEM || defined(DOXYGEN)
624  static uint8_t queueNonlinearMove(uint8_t check_endstops, uint8_t pathOptimize, uint8_t softEndstop);
625  static inline void queueEMove(int32_t e_diff, uint8_t check_endstops, uint8_t pathOptimize);
626  inline uint16_t calculateNonlinearSubSegments(uint8_t softEndstop);
627  static inline void calculateDirectionAndDelta(int32_t difference[], ufast8_t *dir, int32_t delta[]);
628  static inline uint8_t calculateDistance(float axis_diff[], uint8_t dir, float *distance);
629 #if (SOFTWARE_LEVELING && DRIVE_SYSTEM == DELTA) || defined(DOXYGEN)
630  static void calculatePlane(int32_t factors[], int32_t p1[], int32_t p2[], int32_t p3[]);
631  static float calcZOffset(int32_t factors[], int32_t pointX, int32_t pointY);
632 #endif
633 #endif
634 };
635 
636 
637 
638 #endif // MOTION_H_INCLUDED
static void computeMaxJunctionSpeed(PrintLine *previous, PrintLine *current)
Definition: motion.cpp:814
bool isZNegativeMove()
Definition: motion.h:89
int32_t error[E_AXIS_ARRAY]
Error calculation for Bresenham algorithm.
Definition: motion.h:155
void setParameterUpToDate()
Definition: motion.h:204
void setPositiveMoveOfAxis(uint8_t axis)
Definition: motion.h:128
void block()
Definition: motion.h:234
bool isCheckEndstops()
Definition: motion.h:246
uint32_t fAcceleration
accelerationPrim*262144/F_CPU
Definition: motion.h:178
bool isEndSpeedFixed()
Definition: motion.h:216
static void allowInterrupts()
Definition: HAL.h:568
uint8_t getWaitForXLinesFilled()
Definition: motion.h:225
static INLINE void pushLine()
Definition: motion.h:585
static void queueCartesianSegmentTo(uint8_t check_endstops, uint8_t pathOptimize)
Definition: motion.cpp:201
float minSpeed
Definition: motion.h:166
bool isYNegativeMove()
Definition: motion.h:83
ufast8_t joinFlags
Definition: motion.h:147
float endSpeed
Exit speed in mm/s.
Definition: motion.h:165
INLINE void startYStep()
Definition: motion.h:498
bool isXOrZMove()
Definition: motion.h:388
bool isXOrYMove()
Definition: motion.h:385
#define YSTEP
Definition: Repetier.h:190
#define E_STEP_DIRPOS
Definition: Repetier.h:197
static uint8_t calculateDistance(float axis_diff[], uint8_t dir, float *distance)
static void forwardPlanner(ufast8_t p)
Definition: motion.cpp:1000
static INLINE uint8_t isPrinting()
Definition: Printer.h:743
static INLINE void startYStep()
Definition: Printer.h:944
void setXYMoveFinished()
Definition: motion.h:71
Definition: ui.h:588
ticks_t fullInterval
interval at full speed in ticks/step.
Definition: motion.h:174
static INLINE bool yMin()
Definition: Endstops.h:101
#define PRINTLINE_CACHE_SIZE
Number of moves we can cache in advance.
Definition: Configuration.h:1247
#define FLAG_NOMINAL
Definition: motion.h:29
float accelerationDistance2
Real 2.0*distance*acceleration mm²/s²
Definition: motion.h:162
bool isZNegativeMove()
Definition: motion.h:370
bool areParameterUpToDate()
Definition: motion.h:198
static PrintLine lines[]
Cache for print moves.
Definition: motion.h:145
bool isYNegativeMove()
Definition: motion.h:364
float speedX
Speed in x direction at fullInterval in mm/s.
Definition: motion.h:156
static PrintLine * cur
Current printing line.
Definition: motion.h:196
static INLINE void nextPlannerIndex(ufast8_t &p)
Definition: motion.h:620
void setStartSpeedFixed(bool newState)
Definition: motion.h:210
static INLINE bool zMax()
Definition: Endstops.h:122
static volatile int extruderStepsNeeded
This many extruder steps are still needed, <0 = reverse steps needed.
Definition: Printer.h:238
float speedE
Speed in E direction at fullInterval in mm/s.
Definition: motion.h:159
static void LaserWarmUp(uint32_t wait)
Definition: motion.cpp:1118
static uint32_t mulu16xu16to32(unsigned int a, unsigned int b)
Definition: HAL.h:445
void setXYMoveFinished()
Definition: motion.h:352
bool isXNegativeMove()
Definition: motion.h:77
#define FLAG_DECELERATING
Definition: motion.h:30
void setPositiveDirectionForAxis(uint8_t axis)
Definition: motion.h:412
#define XY_STEP
Definition: Repetier.h:195
speed_t vStart
Starting speed in steps/s.
Definition: motion.h:180
bool isMoveOfAxis(uint8_t axis)
Definition: motion.h:406
bool isXNegativeMove()
Definition: motion.h:358
static int8_t motorYorZ
Definition: Printer.h:378
float speedY
Speed in y direction at fullInterval in mm/s.
Definition: motion.h:157
static INLINE uint8_t isAdvanceActivated()
Definition: Printer.h:609
void updateAdvanceSteps(speed_t v, uint8_t max_loops, bool accelerate)
Definition: motion.h:421
#define XYZE_STEP
Definition: Repetier.h:196
uint8_t numNonlinearSegments
Number of delta segments left in line. Decremented by stepper timer.
Definition: motion.h:169
static uint8_t queueNonlinearMove(uint8_t check_endstops, uint8_t pathOptimize, uint8_t softEndstop)
uint8_t flag8_t
Definition: HAL.h:159
static void arc(float *position, float *target, float *offset, float radius, uint8_t isclockwise)
Definition: motion.cpp:2049
static unsigned int mulu6xu16shift16(unsigned int a, unsigned int b)
Definition: HAL.h:472
void invalidateParameter()
Definition: motion.h:201
int32_t stepsRemaining
Remaining steps, until move is finished.
Definition: motion.h:195
secondspeed_t secondSpeed
Definition: motion.h:149
#define FLAG_WARMUP
Definition: motion.h:28
static PrintLine * getNextWriteLine()
Definition: motion.h:595
uint16_t speed_t
Definition: HAL.h:156
static void resetPathPlanner()
Definition: motion.h:415
bool isMoveOfAxis(uint8_t axis)
Definition: motion.h:122
static INLINE void previousPlannerIndex(ufast8_t &p)
Definition: motion.h:617
void setNominalMove()
Definition: motion.h:252
bool isZPositiveMove()
Definition: motion.h:367
bool isStartSpeedFixed()
Definition: motion.h:207
bool isNoMove()
Definition: motion.h:116
#define FLAG_CHECK_ENDSTOPS
Definition: motion.h:32
void setYMoveFinished()
Definition: motion.h:65
static INLINE uint8_t isHoming()
Definition: Printer.h:766
static INLINE bool z2MinMax()
Definition: Endstops.h:129
Definition: motion.h:138
#define FLAG_JOIN_END_FIXED
Definition: motion.h:40
bool isZMove()
Definition: motion.h:107
void setZMoveFinished()
Definition: motion.h:345
bool isXMove()
Definition: motion.h:379
static INLINE bool yMax()
Definition: Endstops.h:108
static INLINE bool xMin()
Definition: Endstops.h:87
float startSpeed
Starting speed in mm/s.
Definition: motion.h:164
Definition: HAL.h:103
INLINE void startZStep()
Definition: motion.h:526
static INLINE void setCurrentLine()
Definition: motion.h:567
static void updateTrapezoids()
Definition: motion.cpp:669
bool isXYZMove()
Definition: motion.h:119
static INLINE void setMenuMode(uint16_t mode, bool on)
Definition: Printer.h:401
bool isZPositiveMove()
Definition: motion.h:86
int32_t timeInTicks
Definition: motion.h:153
uint8_t secondspeed_t
Definition: Repetier.h:217
static float calcZOffset(int32_t factors[], int32_t pointX, int32_t pointY)
NonlinearSegment segments[DELTASEGMENTS_PER_PRINTLINE]
Definition: motion.h:172
static Extruder * current
Definition: Extruder.h:233
bool isZMove()
Definition: motion.h:391
bool isYMove()
Definition: motion.h:101
static void waitForXFreeLines(uint8_t b=1, bool allowMoves=false)
Definition: motion.cpp:1149
static uint32_t stepNumber
Step number in current move.
Definition: Printer.h:272
#define XYZ_STEP
Definition: Repetier.h:194
bool isBlocked()
Definition: motion.h:240
static void calculatePlane(int32_t factors[], int32_t p1[], int32_t p2[], int32_t p3[])
#define FLAG_ALL_E_MOTORS
Definition: motion.h:33
static INLINE void startZStep()
Definition: Printer.h:950
static void moveRelativeDistanceInSteps(int32_t x, int32_t y, int32_t z, int32_t e, float feedrate, bool waitEnd, bool check_endstop, bool pathOptimize=true)
Definition: motion.cpp:104
void setWaitForXLinesFilled(uint8_t b)
Definition: motion.h:228
static uint8_t getLinesCount()
Definition: motion.h:591
fast8_t primaryAxis
Definition: motion.h:151
void setZMoveFinished()
Definition: motion.h:68
#define TOWER_ARRAY
Definition: Repetier.h:134
static INLINE bool xMax()
Definition: Endstops.h:94
Definition: motion.h:58
bool isYPositiveMove()
Definition: motion.h:80
static fast8_t multiZHomeFlags
Definition: Printer.h:369
bool isWarmUp()
Definition: motion.h:222
void setPositiveDirectionForAxis(uint8_t axis)
Definition: motion.h:131
static int8_t motorX
Definition: Printer.h:377
bool isNominalMove()
Definition: motion.h:249
static INLINE bool zProbe()
Definition: Endstops.h:136
float invFullSpeed
1.0/fullSpeed for faster computation
Definition: motion.h:161
bool isEMove()
Definition: motion.h:110
bool isAllEMotors()
Definition: motion.h:243
void setXMoveFinished()
Definition: motion.h:329
void setEndSpeedFixed(bool newState)
Definition: motion.h:219
uint8_t ufast8_t
Definition: HAL.h:161
bool isXPositiveMove()
Definition: motion.h:74
bool isXMove()
Definition: motion.h:98
bool isEPositiveMove()
Definition: motion.h:92
static int32_t bresenhamStep()
Definition: motion.cpp:2545
static INLINE bool isZProbingActive()
Definition: Printer.h:848
bool isExtruderForwardMove()
Definition: motion.h:231
static volatile bool nlFlag
Definition: motion.h:141
uint32_t decelSteps
How much steps does it take, to reach the end speed.
Definition: motion.h:176
#define DELTASEGMENTS_PER_PRINTLINE
Number of delta moves in each line. Moves that exceed this figure will be split into multiple lines...
Definition: Configuration.h:1077
void logLine()
Definition: motion.cpp:1129
INLINE void startXStep()
Definition: motion.h:471
bool isXYZMove()
Definition: motion.h:403
static INLINE bool zMin()
Definition: Endstops.h:115
bool isYMove()
Definition: motion.h:382
#define FLAG_JOIN_STEPPARAMS_COMPUTED
Definition: motion.h:38
static ufast8_t linesPos
Position for executing line movement.
Definition: motion.h:144
INLINE bool moveAccelerating()
Definition: motion.h:468
static INLINE void startXStep()
Definition: Printer.h:923
bool isEPositiveMove()
Definition: motion.h:373
static void calculateDirectionAndDelta(int32_t difference[], ufast8_t *dir, int32_t delta[])
static int advanceStepsSet
Definition: Printer.h:241
float maxJunctionSpeed
Max. junction speed between this and next segment.
Definition: motion.h:163
speed_t vEnd
End speed in steps/s.
Definition: motion.h:181
static void forbidInterrupts()
Definition: HAL.h:576
bool isXOrYMove()
Definition: motion.h:104
int32_t delta[E_AXIS_ARRAY]
Steps we want to move.
Definition: motion.h:154
flag8_t dir
Direction of delta movement.
Definition: motion.h:59
float safeSpeed(fast8_t drivingAxis)
Definition: motion.cpp:1056
void setMoveOfAxis(uint8_t axis)
Definition: motion.h:409
static volatile ufast8_t linesCount
Number of lines cached 0 = nothing to do.
Definition: motion.h:197
bool isEMove()
Definition: motion.h:394
#define FLAG_BLOCKED
Definition: motion.h:35
static INLINE void removeCurrentLineForbidInterrupt()
Definition: motion.h:574
bool isENegativeMove()
Definition: motion.h:376
ufast8_t dir
Direction of movement. 1 = X+, 2 = Y+, 4= Z+, values can be combined.
Definition: motion.h:152
static void queueCartesianMove(uint8_t check_endstops, uint8_t pathOptimize)
Definition: motion.cpp:321
static long advanceExecuted
Executed advance steps.
Definition: Printer.h:243
static INLINE bool hasLines()
Definition: motion.h:564
int8_t fast8_t
Definition: HAL.h:160
#define INLINE
Definition: HAL.h:37
INLINE void setWaitTicks(long wait)
Definition: motion.h:560
speed_t vMax
Maximum reached speed in steps/s.
Definition: motion.h:179
#define MENU_MODE_PRINTING
Definition: Repetier.h:556
static void backwardPlanner(ufast8_t p, ufast8_t last)
Definition: motion.cpp:949
volatile ufast8_t flags
Definition: motion.h:148
#define ZSTEP
Definition: Repetier.h:191
uint32_t ticks_t
Definition: HAL.h:157
uint8_t moveID
ID used to identify moves which are all part of the same line.
Definition: motion.h:170
void calculateMove(float axis_diff[], uint8_t pathOptimize, fast8_t distanceBase)
Definition: motion.cpp:466
void fixStartAndEndSpeed()
Definition: motion.h:213
INLINE long getWaitTicks()
Definition: motion.h:557
#define FLAG_JOIN_START_FIXED
Definition: motion.h:42
static void queueEMove(int32_t e_diff, uint8_t check_endstops, uint8_t pathOptimize)
uint8_t lastMoveID
bool isYPositiveMove()
Definition: motion.h:361
#define Z_STEP_DIRPOS
Definition: Repetier.h:200
#define Y_STEP_DIRPOS
Definition: Repetier.h:198
float distance
Definition: motion.h:167
#define E_AXIS_ARRAY
Definition: Repetier.h:127
static void update()
Definition: Endstops.cpp:35
bool isEOnlyMove()
Definition: motion.h:113
#define ESTEP
Definition: Repetier.h:192
void setMoveOfAxis(uint8_t axis)
Definition: motion.h:125
bool isENegativeMove()
Definition: motion.h:95
static uint32_t timer
used for acceleration/deceleration timing
Definition: Printer.h:271
uint32_t accelerationPrim
Acceleration along primary axis.
Definition: motion.h:177
uint32_t accelSteps
How much steps does it take, to reach the plateau.
Definition: motion.h:175
#define XSTEP
Definition: Repetier.h:189
void setYMoveFinished()
Definition: motion.h:338
#define X_DIRPOS
Definition: Repetier.h:183
bool isXPositiveMove()
Definition: motion.h:355
bool isNoMove()
Definition: motion.h:400
#define X_STEP_DIRPOS
Definition: Repetier.h:199
INLINE bool moveDecelerating()
Definition: motion.h:459
void checkEndstops()
Definition: motion.h:255
bool isEOnlyMove()
Definition: motion.h:397
void updateStepsParameter()
Definition: motion.cpp:897
void setXMoveFinished()
Definition: motion.h:62
int32_t numPrimaryStepPerSegment
Number of primary Bresenham axis steps in each delta segment.
Definition: motion.h:171
static int32_t stepsRemainingAtZHit
Definition: Printer.h:308
float speedZ
Speed in z direction at fullInterval in mm/s.
Definition: motion.h:158
uint16_t calculateNonlinearSubSegments(uint8_t softEndstop)
static void moveRelativeDistanceInStepsReal(int32_t x, int32_t y, int32_t z, int32_t e, float feedrate, bool waitEnd, bool pathOptimize=true)
Definition: motion.cpp:159
float fullSpeed
Desired speed mm/s.
Definition: motion.h:160
void unblock()
Definition: motion.h:237
static uint8_t insertWaitMovesIfNeeded(uint8_t pathOptimize, uint8_t waitExtraLines)
Definition: motion.cpp:1090
static ufast8_t linesWritePos
Position where we write the next cached line move.
Definition: motion.h:146
static INLINE bool anyEndstopHit()
Definition: Endstops.h:68